home *** CD-ROM | disk | FTP | other *** search
- /* FILE: tests.c
- **
- ** Copyright 1990 by Microsoft, All Rights Reserved.
- **
- ** of TESTDRV.EXE
- **
- ** Device Driver Test for MSCDEX compatible CD-ROM.
- ** Tests most aspects of direct driver requests detailed
- ** in Document 000080010-100-O00-1186 Microsoft Device
- ** Driver Specification.
- **
- ** NOTES: The test procedures
- **
- ** HISTORY:
- ** Created 9/1/90 - JYG
- ** 10/01/90 Final (v1.0) -by- JYG
- ** 12/06/91 Revision Siddhartha Roy
- **
- */
-
-
- #include<time.h>
- #include<fcntl.h>
- #include<string.h>
- #include"test.h"
-
- //
- // Default Control Files
- //
- #define NUM_ARCHIVES 4
-
- static char *szArc[] = {
- "SBC.BIN",
- "BOOKS.BIN",
- "MSPL11.BIN",
- "MSPL.BIN"
- };
- char * szTesting = "TESTING";
-
- //
- // Request structures for message reporting
- //
-
- //
- // Local Messages
- //
-
- static char *szLocalMsgs [3] = {
- "Attempt this request",
- "Attempt this test",
- "Does not return DRIVE NOT READY"
- };
-
- /*
- ** TestReservedCmd(Dev_List *)
- ** - These should all promptly return an UNKNOWN COMMAND Error
- ** - Some requests are added if the fWrite flag is FALSE
- **
- ** Explanation:
- ** In this series of tests, we loop over all reserved commands.
- ** We have not made concessions for vendor specific commands.
- **
- */
-
- void TestReservedCmd(drv)
- Dev_List * drv;
- {
- extern FLAG fWriteMedia, fInteract, fVerbose;
-
- //
- // array of unsupported driver requests
- //
-
- static BYTE mplUnSupCmd[] = {
- 0x01,0x02,0x04,0x05,0x06,0x08,0x09,
- 0x0A,0x0F,0x10,0x81,0x0B,0x86,0x87
- };
- static char szMsg1[] = "No Error Returned";
- static char szMsg2[] = "Attempt these requests";
-
- ReqName sLabel;
- WORD wStatus;
- int j;
-
- //
- // Testing IOCTLI reserved Requests
- //
-
- printf( "\n\n[Testing Reserved Requests]\n" );
-
- if ( fInteract && !Ask( szMsg2 ) )
- return;
-
- //
- // Testing codes 0x02, 0x10 - 0xff
- //
- ReportMsg( mRequests[rIRESERVED],"Request Codes 0x02, 0x10 - 0xff" );
-
- if ( !fInteract || Ask( szMsg2 ) )
- {
- sLabel = mRequests[rIRESERVED];
- sLabel.bSubCmd = 2;
-
- StatusTest( wStatus,WDvRqIoiSimple( drv,0x02 ), sLabel );
-
- if ( !(UNKNOWN_CMD&wStatus) )
- ErrorTest( wStatus,sLabel );
- else if ( !(ERRORBIT&wStatus) )
- ErrMsg( sLabel,szMsg1 );
-
- for( j=0x10;j<0xff;j++ )
- {
- sLabel.bSubCmd = (BYTE)j;
- StatusTest( wStatus,WDvRqIoiSimple( drv,(BYTE)j ),sLabel );
-
- if ( !(ERRORBIT&wStatus) )
- ErrMsg( sLabel,szMsg1 );
- else if ( !(UNKNOWN_CMD & wStatus) )
- ErrorTest( wStatus,sLabel );
- }
- }
-
- //
- // IOCTLO reserved Requests 0x06 - 0xff
- //
-
- ReportMsg( mRequests[rORESERVED],"Request Codes 0x06 - 0xff" );
-
- if ( !fInteract || Ask( szMsg2 ) )
- {
- for( j=0x06;j<=0xff;j++ )
- {
- sLabel = mRequests[rORESERVED];
- sLabel.bSubCmd = (BYTE)j;
-
- StatusTest( wStatus,WDvRqIooSimple( drv,(BYTE)j ),sLabel );
- if ( !(ERRORBIT & wStatus) )
- ErrMsg( sLabel,szMsg1 );
- else if ( !(UNKNOWN_CMD & wStatus) )
- ErrorTest( wStatus,sLabel );
- }
- }
-
- //
- // Device request reserved Requests
- // Tests all reserved Requests in mplUnSupCmd
- //
-
- printf( "\nx\t\tReserved Requests: " );
-
- printf( "\n\t\t0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x",mplUnSupCmd[0],
- mplUnSupCmd[1],mplUnSupCmd[2],mplUnSupCmd[3],mplUnSupCmd[4] );
- printf( "\n\t\t0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x",mplUnSupCmd[5],
- mplUnSupCmd[6],mplUnSupCmd[7],mplUnSupCmd[8],mplUnSupCmd[9] );
- printf( "\n\t\t0x%.2x, 0x%.2x",mplUnSupCmd[10],mplUnSupCmd[11] );
- if ( !fWriteMedia )
- printf( ", 0x%.2x, 0x%.2x",mplUnSupCmd[12],mplUnSupCmd[13] );
-
- if ( !fInteract || Ask( szMsg2 ) )
- {
- //
- // If Non-Writable media, do all tests
- //
-
- j=(fWriteMedia)?11:13;
- do
- {
- sLabel = mRequests[rRESERVED];
- sLabel.bSubCmd = mplUnSupCmd[j];
-
- StatusTest( wStatus,WDvRqSimple( drv,mplUnSupCmd[j--] ),sLabel );
- if ( !(ERRORBIT & wStatus) )
- ErrMsg( sLabel,szMsg1 );
- else if ( !(UNKNOWN_CMD & wStatus) )
- ErrorTest( wStatus,sLabel );
- }
- while (j>=0);
- }
-
- //
- // Test Requests 0x11-0x80
- //
-
- printf( "\nx\t\tReserved Requests: 0x11 - 0x80" );
-
- if ( !fInteract || Ask( szMsg2 ) )
- {
- for( j=0x11;j<0x80;j++ )
- {
- sLabel = mRequests[rRESERVED];
- sLabel.bSubCmd = (BYTE)j;
- StatusTest( wStatus,WDvRqSimple( drv,(BYTE) j ),sLabel );
-
- if ( !(ERRORBIT & wStatus) )
- ErrMsg( sLabel,szMsg1 );
- else if ( !(UNKNOWN_CMD & wStatus) )
- ErrorTest( wStatus,sLabel );
- }
- }
- printf( "\n\n[End of Reserved Request Testing]\n" );
-
- }
-
-
- /*
- ** TestDrvBytes(Dev_List *)
- ** - Hex dump of DrvBytes
- ** - Prompts the user if there is redundant information
- */
-
- void TestDrvBytes( drv )
- Dev_List *drv;
- {
- extern FLAG fInteract,fVerbose;
- extern WORD cwSkipped;
-
- DrvBytes_Rec dbrec,olddbrec;
- WORD wStatus;
-
- ReportMsg( mRequests[rIDRVBYTES],"" );
- if ( !fInteract || Ask( szLocalMsgs[0] ) )
- do
- {
- StatusTest( wStatus,WDvRqIoiDrvBytes( drv,&dbrec ),
- mRequests[rIDRVBYTES] );
-
- if ( dbrec.nbytes > 0x80 )
- ErrMsg( mRequests[rIDRVBYTES],"data exceeds 128 bytes" );
-
- //
- // pretty print the buffer
- //
-
- /*
- ** The hexdump is currently de-activated. It can be activated
- ** for more verbose modes.
- */
-
- // HexDump( dbrec.buf,dbrec.nbytes );
-
- if ( dbrec.nbytes < 0x80 )
- break;
-
- if ( !fInteract && !memcmp( dbrec.buf,olddbrec.buf,dbrec.nbytes ) )
- {
- ReportMsg( mRequests[rIDRVBYTES],"Redundant information." );
- break;
- }
-
- if ( fInteract && !Ask( "Continue" ) )
- break;
-
- olddbrec = dbrec;
- }
- //
- // 128bytes indicates more information coming
- //
- while ( dbrec.nbytes == 0x80 );
-
- else cwSkipped++;
- }
-
-
- /*
- ** TestSectorSize(Dev_List *)
- ** - Tests Sector Size for conformance to spec
- */
-
- void TestSectorSize( drv )
- Dev_List *drv;
- {
- extern FLAG fInteract,fVerbose,fRaw;
- extern WORD cwSkipped;
- WORD wSize,wStatus;
-
- ReportMsg( mRequests[rISECTSIZE],"" );
- if ( fInteract && !Ask( szLocalMsgs[1] ) )
- {
- cwSkipped++;
- return;
- }
-
- StatusTest( wStatus,WDvRqIoiSectSize( drv,RAW_MODE,&wSize ),
- mRequests[rISECTSIZE] );
-
- if ( fRaw && !(ERRORBIT&ErrorTest( wStatus,mRequests[rISECTSIZE] )) )
- {
- ReportMsg( mRequests[rISECTSIZE],"Raw size = " );
- printf( "%u",wSize );
- if ( wSize != RAW_SECTOR_SIZE )
- ErrMsg( mRequests[rISECTSIZE],"Returns Bad Raw Sector Size" );
- }
-
- StatusTest( wStatus,WDvRqIoiSectSize( drv,COOKED_MODE,&wSize ),
- mRequests[rISECTSIZE] );
-
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rISECTSIZE] ) )
- return;
-
- ReportMsg( mRequests[rISECTSIZE],"Cooked size = " );
- printf( "%u",wSize );
-
- if ( wSize != COOKED_SECTOR_SIZE )
- {
- ReportMsg( mRequests[rISECTSIZE],"Cooked size = " );
- printf( "%u",wSize );
-
- if ( wSize != COOKED_SECTOR_SIZE )
- ErrMsg( mRequests[rISECTSIZE],"Returns Bad Cooked Sector Size" );
- }
- }
-
-
- /*
- ** TestAudioCtrl(Dev_List *)
- ** - Tests the audio capabilities of the player.
- ** - Manipulates the channels by switching the mappings
- ** and varying the volume levels
- **
- ** left1 (0) right1 (1)
- ** left2 (2) right2 (3)
- */
-
- /*
- ** This test can be expanded to make the playing of music
- ** more interactive, and if failures occur with muting or
- ** controlling volume properly, they can be correctly logged
- ** as errors.
- */
-
-
-
- void TestAudioCtrl(drv)
- Dev_List *drv;
- {
- extern FLAG fAudio, fAudCtrl,fVerbose,fInteract;
- extern WORD cwAudioChan;
-
- WORD wStatus;
- AudInfo_Rec ainfoSnd,ainfoRcv;
-
- //
- // default settings
- // chan: input: volume:
- // 0 0 0xff
- // 1 1 0xff
- // 2 2 0x00
- // 3 3 0x00
- //
-
- static AudInfo_Rec ainfoPri = {
- 0x04,0x00,0xff,0x01,0xff,
- 0x02,0x00,0x03,0x00
- };
-
- mRequests[rOAUDINFO] = mRequests[rOAUDINFO];
-
- if ( fAudio && fAudCtrl && (!fInteract ||
- Ask( "Attempt audio control requests" )) )
- {
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
-
- ErrorTest( wStatus,mRequests[rIAUDINFO] );
-
- if ( !(ERRORBIT&wStatus) && fVerbose )
- PrintAudInfo( ainfoRcv );
-
- if ( !(BUSYBIT&wStatus) )
- WarningMsg( mRequests[rIAUDINFO],"Busybit status not set" );
-
- //
- // *** turn off left1 channel
- //
-
- ReportMsg( mRequests[rOAUDINFO],"Channel 0 off, Channel 1 full volume" );
-
- ainfoSnd = ainfoRcv;
- ainfoSnd.vol1 = 0xff;
- ainfoSnd.vol0 = 0x00;
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoSnd ),
- mRequests[rOAUDINFO] );
-
- ErrorTest( wStatus,mRequests[rOAUDINFO] );
-
- if ( fInteract )
- {
- if ( Ask( "Is channel 0 mute" ) )
- ReportMsg( mRequests[rOAUDINFO],"Correctly mutes channel 0" );
- else
- ErrMsg( mRequests[rOAUDINFO],"Fails to mute channel 0" );
- }
-
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDINFO] )) )
- {
- PrintAudInfo( ainfoRcv );
-
- if ( !AINFEQU( ainfoRcv,ainfoSnd ) )
- ErrMsg( mRequests[rIAUDINFO],"Audio control request failed" );
- }
-
- //
- // *** turn off right1
- //
-
- ReportMsg( mRequests[rOAUDINFO],"Channel 0 full volume, Channel 1 off" );
-
- ainfoSnd.vol1 = 0x00; // turn off right1 channel
- ainfoSnd.vol0 = 0xff; // turn on left1 channel
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoSnd ),mRequests[rOAUDINFO] );
- ErrorTest( wStatus,mRequests[rOAUDINFO] );
-
- if ( fInteract )
- {
- if ( Ask( "Is channel 1 mute" ) )
- ReportMsg( mRequests[rOAUDINFO],"Correctly mutes channel 1" );
- else
- ErrMsg( mRequests[rOAUDINFO],"Fails to mute channel 1" );
- }
-
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDINFO] )) )
- {
- PrintAudInfo( ainfoRcv );
- if ( !AINFEQU( ainfoRcv,ainfoSnd ) )
- ErrMsg( mRequests[rOAUDINFO],"Audio control request failed" );
- }
-
- //
- // *** Swapping Channel 0 and 1
- //
-
- ReportMsg( mRequests[rOAUDINFO],"Swapping channel 0 and channel 1 inputs" );
-
- ainfoSnd.vol1 = 0xff; // turn on right1 channel
-
- ainfoSnd.in0 = 0x01; // swap left1 and right1 channels
- ainfoSnd.in1 = 0x00;
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoSnd ),
- mRequests[rOAUDINFO] );
- ErrorTest( wStatus,mRequests[rOAUDINFO] );
-
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDINFO] )) )
- {
- PrintAudInfo( ainfoRcv );
- if ( !AINFEQU( ainfoRcv,ainfoSnd ) )
- ErrMsg( mRequests[rOAUDINFO],"Audio control request failed" );
- }
-
- //
- // Muting all channels
- //
-
- ReportMsg( mRequests[rOAUDINFO],"Muting all Channels" );
-
- ainfoSnd.vol0 = 0x00; // turn off right1 channel
- ainfoSnd.vol1 = 0x00; // turn off right1 channel
- ainfoSnd.vol2 = 0x00; // turn off right1 channel
- ainfoSnd.vol3 = 0x00; // turn off right1 channel
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoSnd ),mRequests[rOAUDINFO] );
- ErrorTest( wStatus,mRequests[rOAUDINFO] );
-
- if ( fInteract )
- {
- if ( Ask( "Are all channels mute" ) )
- ReportMsg( mRequests[rOAUDINFO],"Correctly mutes all channels " );
- else
- ErrMsg( mRequests[rOAUDINFO],"Fails to mute all channels " );
- }
-
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDINFO] )) )
- {
- PrintAudInfo( ainfoRcv );
- if ( !AINFEQU( ainfoRcv,ainfoSnd ) )
- ErrMsg( mRequests[rOAUDINFO],"Audio control request failed" );
- }
-
- //
- // *** reset channels
- //
-
- ReportMsg( mRequests[rOAUDINFO],"Restoring Audio Characteristics" );
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoPri ),
- mRequests[rOAUDINFO] );
- ErrorTest( wStatus,mRequests[rOAUDINFO] );
-
- StatusTest( wStatus,WDvRqIoiAudInfo( drv,&ainfoRcv ),
- mRequests[rIAUDINFO] );
- ErrorTest( wStatus,mRequests[rIAUDINFO] );
-
- if ( !AINFEQU( ainfoRcv,ainfoPri ) )
- ErrMsg( mRequests[rOAUDINFO],"Audio control request failed" );
-
- ReportMsg( mRequests[rOAUDINFO],"Changing channel volume from 0x00 to 0xff" );
-
- ainfoSnd = ainfoPri;
-
- //
- // Restore the original settings
- //
-
- StatusTest( wStatus,WDvRqIooAudInfo( drv,&ainfoPri ),
- mRequests[rOAUDINFO] );
- }
- }
-
- /*
- ** TestSeek(Dev_List *, DWORD, BYTE)
- ** - test a seek:
- ** We attempt to seek to a sector and monitor the Head Location
- ** for movement. The test ceases when the head is in the requested
- ** position OR timeout requirements are met.
- */
-
- #define MAXWAIT 100
- #define MAXTIME 10
-
- void TestSeek( drv,lSector,chAddrMode )
- Dev_List * drv;
- DWORD lSector;
- BYTE chAddrMode;
- {
- extern FLAG fInteract,fVerbose;
- extern WORD cwSkipped;
-
- WORD wWait,wTimeOut,wStatus;
- DWORD dwLoc,dwPrevLoc,dwPrevPrevLoc,dwStartLoc;
-
- ReportMsg( mRequests[rSEEK],"Attempting to seek to " );
- if ( chAddrMode == REDBOOK_ADDRMODE ){
- PrintRed( lSector );
- }
- else
- printf( "%lx",lSector );
-
- if ( fInteract && !Ask( "Attempt seek" ) )
- {
- cwSkipped++;
- return;
- }
-
- StatusTest( wStatus,WDvRqIoiLocHead( drv,chAddrMode,&dwStartLoc ),
- mRequests[rILOCHEAD] );
- ErrorTest( wStatus,mRequests[rILOCHEAD] );
-
- StatusTest( wStatus,WDvRqSeek( drv,lSector,chAddrMode ),
- mRequests[rSEEK] );
- ErrorTest( wStatus,mRequests[rSEEK] );
-
- dwLoc = dwStartLoc;
- dwPrevLoc = dwStartLoc;
-
-
- //
- // In this loop, we check for continuous motion of the drive head
- // If the head is stopped or moves in the reverse direction, the
- // loop will start to time out.
- //
-
- for ( wTimeOut=0,wWait=0;wTimeOut<MAXTIME && dwLoc!=lSector;wWait++ )
- {
- dwPrevPrevLoc = dwPrevLoc;
- dwPrevLoc = dwLoc;
-
- StatusTest( wStatus,WDvRqIoiLocHead( drv,chAddrMode,&dwLoc ),
- mRequests[rILOCHEAD] );
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rILOCHEAD] ) )
- return;
-
- if ( dwLoc>dwPrevLoc && lSector>dwPrevLoc )
- {
- if ( chAddrMode == REDBOOK_ADDRMODE )
- {
- printf( "\n\t\tMoved outwards(+) " );
- PrintRed( RedDiff( dwLoc,dwPrevLoc ) );
- printf( " Sectors, from " );
- PrintRed( dwPrevLoc );
- printf( " to ");
- PrintRed (dwLoc);
- }
- else
- printf( "\n\t\tMoved +%lx Sectors %lx",dwPrevLoc-dwLoc,dwLoc );
- if ( dwPrevLoc > dwPrevPrevLoc )
- wTimeOut = 0;
- else wTimeOut++;
- }
- else if ( dwLoc<dwPrevLoc && lSector<dwPrevLoc )
- {
- if ( chAddrMode==REDBOOK_ADDRMODE )
- {
- printf( "\n\t\tMoved inwards(-)" );
- PrintRed( RedDiff( dwLoc,dwPrevLoc ) );
- printf( " Sectors, from " );
- PrintRed( dwPrevLoc );
- printf( " to ");
- PrintRed( dwLoc );
- }
- else
- printf( "\n\t\tMoved -%lx Sectors %lx",dwPrevLoc-dwLoc,dwLoc );
-
- if ( dwPrevLoc < dwPrevPrevLoc )
- wTimeOut = 0;
- else wTimeOut++;
- }
- else wTimeOut++;
- }
-
- if ( chAddrMode==REDBOOK_ADDRMODE )
- {
- printf( "\n\t\tStarting Head Location [REDBOOK] " );
- PrintRed( dwStartLoc );
- printf( "\n\t\tEnding Head Location [REDBOOK] " );
- PrintRed( dwLoc );
- }
- else
- {
- printf( "\n\t\tStarting Head Location %lx [HSG]",
- dwStartLoc );
- printf( "\n\t\tEnding Head Location %lx [HSG]",
- dwLoc );
- }
- }
-
- /*
- ** TestUPCCode(Dev_List *)
- ** - Try and locate a UPC code on the disk. If we find it, we print it out
- */
-
- /*
- ** Since some discs DO NOT have UPC information, they will
- ** return errors when attempts to find UPC information.
- ** Returned errors can also mean errors with the drivers, to
- ** ascertain that the error is with the driver, UPC information
- ** can also be acquired through the Q Channel
- */
-
- void TestUPCCode( drv )
- Dev_List * drv;
- {
- //
- // IOCTLI UPC Code Test
- //
-
- extern FLAG fUPC,fInteract,fVerbose;
- WORD wStatus;
- UPCCode_Rec upc;
-
- ReportMsg( mRequests[rIUPCCODE],"" );
-
- if ( !fInteract || Ask( szLocalMsgs[0] ) )
- {
- StatusTest( wStatus,WDvRqIoiUPCCode( drv,&upc ),mRequests[rIUPCCODE] );
- if ( fUPC )
- {
- if ( !(ERRORBIT&wStatus) )
- {
- if ( upc.ctrl_adr!=2 )
- {
- WarningMsg( mRequests[rIUPCCODE],"Control and ADR = " );
- printf( "%.2x\n",upc.ctrl_adr );
- }
-
- ReportMsg( mRequests[rIUPCCODE],"UPC/EAN code " );
-
- // 13 succesive BCD digits , followed by 12 bits of zero
-
- printf( "%.2x%.2x%.2x%.2x%.2x%.2x%.2x",upc.upc[0],
- upc.upc[1],upc.upc[2],upc.upc[3],upc.upc[4],
- upc.upc[5],upc.upc[6] );
-
- }
- else if ( SECTOR_NOT_FND&wStatus )
- ReportMsg( mRequests[rIUPCCODE],"No UPC info OR UPC info missed" );
- else
- ErrorTest( wStatus,mRequests[rIUPCCODE] );
- }
- else if ( UNKNOWN_CMD&wStatus )
- ReportMsg( mRequests[rIUPCCODE],"Correctly returns UNKNOWN Request" );
- else
- ErrMsg( mRequests[rIUPCCODE],"Does not return UNKNOWN Request" );
- }
- }
-
- /*
- ** void TestVolSize(Dev_List *)
- ** - Volume Size Test
- */
-
- /*
- ** The volume size can be cross checked by the formula
- ** 60*75*min+75*sec + frames
- */
-
- void TestVolSize(drv)
- Dev_List * drv;
- {
- extern FLAG fInteract,fVerbose;
- WORD wStatus;
- DWORD size;
-
- ReportMsg( mRequests[rIVOLSIZE],"" );
-
- if ( !fInteract || Ask( szLocalMsgs[0] ) )
- {
-
- StatusTest( wStatus,WDvRqIoiVolSize( drv,&size ),mRequests[rIVOLSIZE] );
- if ( !(ERRORBIT&wStatus) )
- {
- ReportMsg( mRequests[rIVOLSIZE],"Number of sectors = " );
- printf( "%ld",size );
- }
- else
- ErrorTest( wStatus,mRequests[rIVOLSIZE] );
-
- }
- }
-
- /*
- ** TestAudioDisk(Dev_List)
- ** - Calls: IOCTLI - LocHead, DiskInfo, TnoInfo, Qinfo, SubChanInfo, AudStat
- ** - Calls: PlayReq, ResumeReq, StopReq
- ** - Calls: TestAudioCtrl()
- */
-
- void TestAudioDisk( drv )
- Dev_List * drv;
- {
- extern FLAG fInteract,fVerbose,fAudCtrl,fSubInfo;
- extern DWORD mplRedSector[];
- extern WORD cwRedSectors;
- WORD wStatus;
- DiskInfo_Rec dinfo;
- TnoInfo_Rec tno;
- DWORD loc;
- BYTE i;
- QchanInfo_Rec qinfo;
- AudStat_Rec audstatRec;
-
- printf("\n\n[AUDIO TESTS]\n");
-
- if ( fInteract && !Ask( "Is this an Audio Disk" ) )
- return;
-
- StatusTest( wStatus,WDvRqIoiDiskInfo( drv,&dinfo ),mRequests[rIDISKINFO] )
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rIDISKINFO] ) )
- {
- WarningMsg( mRequests[rIDISKINFO],"Skipping Track Info, Seek requests" );
- WarningMsg( mRequests[rITNOINFO],"Skipping Play, Stop, Resume requests" );
- return;
- }
-
-
- //
- // SEEK to end (the sector before the lead out) and test lochead
- //
-
-
- // We try to seek to one before since the lead out track points to the first
- // sector the last addresable sector
-
- ReportMsg( mRequests[rIDISKINFO],"" );
- printf( "lowest track # %d :: highest track # %d",dinfo.low_track,dinfo.hi_track );
-
- ReportMsg( mRequests[rIDISKINFO],"Lead out RedBook address = " );
- PrintRed (dinfo.start);
-
- ReportMsg( mRequests[rITNOINFO],"" );
-
- //
- // Read the track information and do a seek to each track
- //
- for ( i=dinfo.low_track; i <= dinfo.hi_track ; i++ )
- {
- wStatus=WDvRqIoiTnoInfo( drv,i,&tno );
- printf("\n");
- InterpStatus(wStatus);
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rITNOINFO] )) )
- {
-
- printf( "\tTrack # %d ",i);
- PrintRed(tno.start_tno);
- printf( " \tControl Info %.2x",tno.tcntrl);
- }
- }
-
- ReportMsg( mRequests[rPLAY],"Track " );
- printf( "%d",dinfo.low_track );
-
- //
- // Find the lowest track address and begin playing
- //
-
- StatusTest( wStatus,WDvRqIoiTnoInfo( drv,dinfo.low_track,&tno ),
- mRequests[rITNOINFO] );
-
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rITNOINFO] ) )
- {
- WarningMsg( mRequests[rIDISKINFO],"Skipping Track Info Requests" );
- WarningMsg( mRequests[rITNOINFO],"Skipping Play, Stop, Resume requests" );
- return;
- }
-
- // First track specfied in testdrv.pro
- // Keep this option open too thru a boolean flag in testdrv.pro
-
- StatusTest( wStatus,WDvRqPlay( drv,mplRedSector[0],red2hsg(RedDiff( mplRedSector[0], dinfo.start )),REDBOOK_ADDRMODE ),mRequests[rPLAY] );
-
- if ( !(BUSYBIT&ErrorTest( wStatus,mRequests[rPLAY] )) )
- ErrMsg( mRequests[rPLAY],"Does not return BUSY" );
- else {
- printf(" \nPlaying track from "); PrintRed(mplRedSector[0]) ;
- }
-
- //
- // For now, try to read 10 sectors worth of sub channel information
- //
-
- // This ioctl is generally useful during an AUDIO play request
- // We expect the info to be delivered in real time
-
- if ( fSubInfo )
- TestSubInfo ( drv, tno.start_tno, 10 );
-
- //
- // Query if the music is playing.
- //
-
- if ( fInteract )
- {
- if ( Ask( "Can you hear music playing" ) )
- ReportMsg( mRequests[rPLAY],"Request Completed Sucessfully." );
- else
- WarningMsg( mRequests[rPLAY],"No Audio Response" );
- }
-
- //
- // Short Testing loop for the Qchannel
- //
-
- // Track info is returned in hex
- for ( i=1;i<=5;i++ )
- {
- printf("\n=======================================================================");
- printf("\n\t Q Channel Sample #%d\n",i);
- if (fInteract){
- printf("Note the statistics when head is moving \n");
- printf("Press any key to proceed ....\n");
- getch();
- }
-
- StatusTest( wStatus,WDvRqIoiQinfo( drv,&qinfo ),mRequests[rIQINFO] );
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rIQINFO] ) )
- break;
-
- StatusTest( wStatus,WDvRqIoiLocHead( drv,REDBOOK_ADDRMODE,&loc ),
- mRequests[rILOCHEAD] );
- if ( ERRORBIT&ErrorTest( wStatus,mRequests[rILOCHEAD] ) )
- break;
-
- printf( "\n #%d Qinfo: Cntrl %d, Track %x, P/Index %d, Track Running Time %d:%d:%d\nDisk running time: %d:%d:%d",i,
- qinfo.ctrl,qinfo.tno,qinfo.x,qinfo.min,qinfo.sec,qinfo.frame,qinfo.pmin,
- qinfo.psec,qinfo.pframe );
- printf( "\nLocation of Head " );PrintRed(loc);
- }
-
- //
- // Attempt Audio Control Testing
- //
-
- if ( fAudCtrl )
- TestAudioCtrl( drv );
-
-
- if ( fInteract && Ask( "Test Stop and Pause" ) )
- {
- //
- // test pause
- //
-
- ReportMsg( mRequests[rSTOP],"Pausing" );
-
- StatusTest( wStatus,WDvRqStop( drv ),mRequests[rSTOP] );
- ErrorTest( wStatus,mRequests[rSTOP] );
-
- StatusTest( wStatus,WDvRqIoiAudStat( drv,&audstatRec ),
- mRequests[rIAUDSTAT] );
- ErrorTest( wStatus,mRequests[rIAUDSTAT] );
-
- if ( !Ask( "Did the music pause" ) )
- ErrMsg( mRequests[rSTOP],"Fails to pause" );
-
- if ( !(ERRORBIT&wStatus) )
- {
- if ( audstatRec.stat_bits&AUDIO_PAUSEDBIT )
- ReportMsg( mRequests[rSTOP],"PAUSED Correctly" );
- else
- ErrMsg( mRequests[rSTOP],"Failed to pause" );
- }
-
- ReportMsg( mRequests[rRESUME],"" );
-
- StatusTest( wStatus,WDvRqResume( drv ),mRequests[rRESUME] );
- ErrorTest( wStatus,mRequests[rRESUME] );
-
- if ( !Ask("Did the music resume" ) )
- ErrMsg( mRequests[rRESUME],"Did not resume" );
-
- StatusTest( wStatus,WDvRqResume( drv ),mRequests[rRESUME] );
-
- if ( !(ERRORBIT&wStatus) )
- ErrMsg( mRequests[rRESUME],"Second Call to Resume did not return in error" );
-
- //
- // Test Pause again
- //
-
- ReportMsg( mRequests[rSTOP],"Pausing" );
-
- StatusTest( wStatus,WDvRqStop( drv ),mRequests[rSTOP] );
- ErrorTest( wStatus,mRequests[rSTOP] );
-
- StatusTest( wStatus,WDvRqIoiAudStat( drv,&audstatRec ),
- mRequests[rIAUDSTAT] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDSTAT] )) )
- {
- if ( audstatRec.stat_bits&AUDIO_PAUSEDBIT )
- ReportMsg( mRequests[rSTOP],"PAUSED Correctly" );
- else
- ErrMsg( mRequests[rSTOP],"Failed to pause" );
- }
-
- //
- // Test Stop
- //
-
- ReportMsg( mRequests[rSTOP],"" );
-
- StatusTest( wStatus,WDvRqStop( drv ),mRequests[rSTOP] );
- ErrorTest( wStatus,mRequests[rSTOP] );
-
- StatusTest( wStatus,WDvRqIoiAudStat( drv,&audstatRec ),
- mRequests[rIAUDSTAT] );
-
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIAUDSTAT] )) )
- {
- if ( audstatRec.stat_bits&AUDIO_PAUSEDBIT )
- ErrMsg( mRequests[rSTOP],"Failed to stop" );
- else if ( audstatRec.start_tno != 0 && audstatRec.end_tno != 0 )
- ErrMsg( mRequests[rSTOP],"Failed to reset pause statistics" );
- }
- }
-
- //
- // Make sure its stopped
- //
-
- WDvRqStop(drv);
- printf( "\n\n[End of Audio Tests]" );
-
- }
- /*
- ** void TestSubInfo(Dev_List *, DWORD, DWORD)
- ** - Dump Sub Channel Information.
- */
- // The idea is to take a RedBook address of a particular
- // sector/frame and copy the sub channel info for each
- // to the txf address . For multiple sectors copy info
- // sequentially (96 bytes /sector)
-
- void TestSubInfo(drv,dwAddr,dwNum)
- DWORD dwAddr, dwNum;
- Dev_List * drv;
- {
- extern FLAG fVerbose, fSubInfo;
- BYTE _far * xfer;
- WORD wStatus;
-
- if (xfer = (BYTE _far *) my_malloc ((WORD)dwNum * 96))
- {
- StatusTest (wStatus,WDvRqIoiSubChInfo(drv,dwAddr,xfer,dwNum),
- mRequests[rISUBINFO]);
- if (fSubInfo)
- {
- if (!(ERRORBIT&wStatus))
- {
- ReportMsg(mRequests[rISUBINFO],"Sub Channel Info returned:");
- HexDump( xfer, (WORD)dwNum*96 );
- }
- else
- ErrorTest(wStatus,mRequests[rISUBINFO]);
- }
- else if (!(ERRORBIT&wStatus))
- ErrMsg(mRequests[rISUBINFO],"No Error Returned.");
- else if (!(UNKNOWN_CMD&wStatus))
- ErrMsg(mRequests[rISUBINFO],"Does not return UNKNOWN COMMAND");
- }
-
- if (xfer)
- my_free(xfer);
- }
-
-
- /*
- ** void TestEject(Dev_List *)
- **
- */
- void TestEject( drv )
- Dev_List * drv;
- {
- extern FLAG fEject, fInteract, fVerbose, fAudio, fPrefetch;
- extern WORD cwSkipped;
-
- char chMedChng;
- WORD wStatus;
- DWORD lStatWord;
- BYTE _far * lpbBuf;
-
- // Eject Testing
- // Most drives allow ejecting, though many use the disc
- // caddy and cannot return. This must be an attended
- // operation.
-
- printf( "\n\n[EJECT TEST]\n" );
-
- if ( !fEject )
- {
- StatusTest( wStatus, WDvRqIooEject( drv ),mRequests[rOEJECT] );
- if ( !(wStatus&(UNKNOWN_CMD|ERRORBIT)) )
- ErrMsg( mRequests[rOEJECT],
- "Driver does not return UNKNOWN COMMAND" );
- }
- else if ( Ask( szLocalMsgs[1] ) )
- {
-
- StatusTest( wStatus,WDvRqIooEject( drv ),mRequests[rOEJECT] );
- ErrorTest( wStatus,mRequests[rOEJECT] );
-
- if ( Ask( "Did the Disk Eject" ) )
- ReportMsg( mRequests[rOEJECT],"Correctly Ejects disk." );
- else
- {
- ErrMsg( mRequests[rOEJECT],"Failure" );
- printf( "\n\t\tPlease MANUALLY eject the disk" );
- printf( "\n\t\tPress any key." );
- getch();
- }
-
- StatusTest( wStatus,WDvRqIoiDevStat( drv,&lStatWord ),
- mRequests[rIDEVSTAT] );
- ErrorTest( wStatus,mRequests[rIDEVSTAT] );
-
- if ( !(lStatWord&DEVSTAT_NODISK) )
- ErrMsg( mRequests[rIDEVSTAT],
- "Driver still detects a disk is in the drive" );
- //
- // Test the MediaChanged byte
- //
-
- ReportMsg( mRequests[rIMEDCHNG],"" );
-
- if ( Ask( szLocalMsgs[0] ) )
- {
- StatusTest( wStatus,WDvRqIoiMedChng( drv,&chMedChng ),
- mRequests[rIMEDCHNG] );
- ErrorTest( wStatus,mRequests[rIMEDCHNG] );
-
- switch ( chMedChng )
- {
- case 1:
- ErrMsg( mRequests[rIMEDCHNG],"Still thinks Media Not Changed" );
- break;
- case 0:
- WarningMsg( mRequests[rIMEDCHNG],"Does not know if Media Changed" );
- break;
- case -1:
- ReportMsg( mRequests[rIMEDCHNG],"Reports Media Changed" );
- break;
- default:
- ErrMsg( mRequests[rIMEDCHNG],"Call returns a value not 1,0,-1" );
- break;
- }
- }
- else cwSkipped++;
-
- {
- //
- // Attempt a ReadL, ReadLPre, Play, Seek on an open drive.
- //
-
- extern FLAG fInteract;
- extern time_t time(time_t *);
- time_t cTimeStart,cTimeFinish;
- DWORD vsize;
-
- if ( Ask( "Test ReadL on an open drive" ) )
- {
-
- lpbBuf = my_malloc( (size_t)RAW_SECTOR_SIZE );
-
- ReportMsg( mRequests[rREADL],"Testing Read on open drive" );
-
- time( &cTimeStart );
-
- StatusTest( wStatus,WDvRqReadL( drv,(BYTE _far *)lpbBuf,0L,
- (WORD)1,HSG_ADDRMODE,COOKED_MODE,0,0 ),mRequests[rREADL] );
- if ( !((ERRORBIT|DONEBIT|DRV_NOT_READY)&wStatus) )
- ErrMsg( mRequests[rREADL],
- "Does not return DRIVE NOT READY error" );
- time( &cTimeFinish );
- printf( "\n\t\tTimeout took: %ld sec",cTimeFinish-cTimeStart );
- my_free( lpbBuf );
- }
- else cwSkipped++;
-
- if ( fPrefetch && Ask( "Test ReadLPre on an open drive" ) )
- {
- StatusTest( wStatus,WDvRqReadLPre( drv,0L,(WORD)1,
- HSG_ADDRMODE,COOKED_MODE,0,0 ),mRequests[rREADLPRE] );
-
- if ( !((ERRORBIT|DONEBIT|DRV_NOT_READY)&wStatus) )
- ErrMsg( mRequests[rREADLPRE],
- szLocalMsgs[2]);
- }
- else cwSkipped++;
-
- if ( Ask( "Test IOCTLI:VolSize on an open drive" ) )
- {
- StatusTest( wStatus,WDvRqIoiVolSize( drv, &vsize ),
- mRequests[rIVOLSIZE] );
- if ( !((ERRORBIT|DONEBIT|DRV_NOT_READY)&wStatus) )
- ErrMsg( mRequests[rIVOLSIZE], szLocalMsgs[2] );
- }
-
- if ( Ask( "Test Seek on an open drive" ) )
- {
- StatusTest( wStatus,WDvRqSeek( drv,0L,HSG_ADDRMODE ),
- mRequests[rSEEK] );
- if ( !((ERRORBIT|DONEBIT|DRV_NOT_READY)&wStatus) )
- ErrMsg( mRequests[rSEEK],
- szLocalMsgs[2]);
- }
- else cwSkipped++;
-
- if ( fAudio && Ask( "Test Play on an open drive" ) )
- {
- StatusTest( wStatus,WDvRqPlay( drv,0L,0x0000ffff,
- HSG_ADDRMODE ),mRequests[rPLAY] );
- if ( !((ERRORBIT|DONEBIT|DRV_NOT_READY)&wStatus) )
- ErrMsg( mRequests[rPLAY],
- szLocalMsgs[2]);
- }
- else cwSkipped++;
-
- }
-
- StatusTest( wStatus,WDvRqIooCloseTray( drv ),mRequests[rOCLOSETRAY] );
- ErrorTest( wStatus,mRequests[rOCLOSETRAY] );
-
- if ( Ask( "Did the Disk Close" ) )
- ReportMsg( mRequests[rOCLOSETRAY],"Correctly Closes Tray." );
- else
- {
- WarningMsg( mRequests[rOCLOSETRAY],"Cannot Close Tray." );
- printf( "\n\t\tPlease manually close the tray" );
- printf( "\n\t\tPress any key when closed." );
- getch();
- }
-
- StatusTest( wStatus,WDvRqIoiDevStat( drv,&lStatWord ),
- mRequests[rIDEVSTAT] );
- ErrorTest( wStatus,mRequests[rIDEVSTAT] );
-
- if ( lStatWord&DEVSTAT_NODISK )
- ErrMsg( mRequests[rIDEVSTAT],"Unable to detect a disk in the drive" );
- }
- printf( "\n\n[End of EJECT TEST]\n" );
- }
-
- /*
- ** WORD TestRead(Dev_List *,DWORD,BYTE,BYTE,char _far *)
- **
- */
-
- WORD TestRead( drv,lSector,bAddrMode,bReadMode,lpInBuf )
- Dev_List * drv;
- DWORD lSector;
- BYTE bAddrMode,bReadMode;
- BYTE _far * lpInBuf;
- {
- extern BYTE bInterSize,bInterSkip;
- extern FLAG fVerbose,fInterleave,fPrefetch;
-
- WORD wStatus;
-
- if (fPrefetch)
- {
- if ( fInterleave )
- {
- StatusTest( wStatus,WDvRqReadLPre( drv,lSector,1,bAddrMode,
- bReadMode,bInterSize,bInterSkip ),mRequests[rREADLPRE] );
- }
- else
- {
- StatusTest( wStatus,WDvRqReadLPre( drv,lSector,1,bAddrMode,
- bReadMode,0x0,0x0 ),mRequests[rREADLPRE] );
- }
- ErrorTest( wStatus,mRequests[rREADLPRE] );
- }
-
-
-
- if ( fInterleave )
- {
- StatusTest( wStatus,WDvRqReadL( drv,(BYTE _far *)lpInBuf,lSector,1,
- bAddrMode,bReadMode,bInterSize,bInterSkip ),mRequests[rREADL] );
- }
- else
- {
- StatusTest( wStatus,WDvRqReadL( drv,(BYTE _far *)lpInBuf,lSector,1,
- bAddrMode,bReadMode,0x0,0x0 ),mRequests[rREADL] );
- }
-
- ErrorTest( wStatus,mRequests[rREADL] );
- return wStatus;
- }
-
- /*
- ** TestControl(Dev_List *)
- ** - verifies correctness of disk information against
- ** control data
- **
- */
-
- void TestControl( drv )
- Dev_List * drv;
- {
- extern FLAG fInteract,fUPC,fVerbose,fRaw;
- extern char * szStdPath;
- extern WORD wDriveNum;
-
- BYTE _far * lpbArcBuf; // Archive Buffer
- BYTE _far * lpbDiscBuf; // Disc Read Buffer
-
- char szDiskTitle[256],szFullPath[256],len;
- char szArcVolLabel[13],szDiskVolLabel[13];
-
- DWORD lSector,vsizeDisc,vsizeArc;
- BYTE bEquiv,fVolErr,fUPCErr,iTrack,bAddrMode,bReadMode;
- WORD iArc,wStatus,wNum;
- int fh; // file handle to the Archive file
-
- UPCCode_Rec upcDisc,upcArc;
- DiskInfo_Rec dinfoDisc,dinfoArc;
- TnoInfo_Rec tinfoDisc,tinfoArc;
-
- printf( "\n\n[SECTOR MATCHING TESTS]\n" );
-
-
- if ( fInteract && !Ask( szLocalMsgs[1] ) )
- return;
-
- //
- // Try to get a VOLUME SIZE
- //
-
- StatusTest( wStatus,WDvRqIoiVolSize( drv,&vsizeDisc ),
- mRequests[rIVOLSIZE] );
-
- if ( ERRORBIT&wStatus )
- {
- fVolErr = TRUE;
- ErrorTest( wStatus,mRequests[rIVOLSIZE] );
- }
- else
- {
- fVolErr = FALSE;
- if ( fVerbose )
- {
- ReportMsg( mRequests[rIVOLSIZE], "Volume Size = ");
- printf( "%lu",vsizeDisc);
- }
- }
-
- //
- // Try to get a UPC code
- //
-
- if ( fUPC )
- {
- StatusTest( wStatus,WDvRqIoiUPCCode( drv,&upcDisc ),
- mRequests[rIUPCCODE] );
-
- if ( ERRORBIT&wStatus )
- {
- fUPCErr = TRUE;
- ErrorTest( wStatus,mRequests[rIUPCCODE] );
- }
- else
- fUPCErr = FALSE;
- }
- else
- fUPCErr = TRUE;
-
- //
- // Try to get the VTOC information
- //
-
- StatusTest( wStatus,WDvRqIoiDiskInfo( drv,&dinfoDisc ),
- mRequests[rIDISKINFO] );
- ErrorTest( wStatus,mRequests[rIDISKINFO] );
-
- if ( ERRORBIT&wStatus )
- {
- ErrMsg( mRequests[rIDISKINFO],"Insufficient Disk Information to continue" );
- ReportMsg( mRequests[rIDISKINFO],"Falling through to plain Sector Dump" );
- SectorDump( drv );
- return;
- }
-
- // Identify the archive or call hex dump
- // Assumption: if a structure from the archive has a
- // code field == 0, the call that relates the structure
- // was unsupported on archive creation.
-
- lpbArcBuf = my_malloc( (size_t)RAW_SECTOR_SIZE );
- lpbDiscBuf = my_malloc( (size_t)RAW_SECTOR_SIZE );
-
- // This is the place where the four .bin files are being
- // read in .testdrv assumes that there is always a
- // Bookshelf .Make this feature interactive ..
- // Ask the user , if Yes , then read in 4 files etc
-
- for( iArc=0;iArc<NUM_ARCHIVES;iArc++,bEquiv=FALSE )
-
- {
- if ( szStdPath )
- sprintf( szFullPath,"%s\\%s",szStdPath,szArc[iArc] );
- else
- sprintf( szFullPath,"%s",szArc[iArc] );
-
- printf( "\nTesting %s\n",szFullPath );
-
- if ( _dos_open( szFullPath,O_RDONLY, &fh ) == 0 )
- {
- _dos_read(fh,&len,1,&wNum);
- _dos_read(fh,szDiskTitle,len,&wNum);
- _dos_read(fh,&upcArc,sizeof(UPCCode_Rec),&wNum);
- _dos_read(fh,&dinfoArc,sizeof( DiskInfo_Rec ),&wNum);
- _dos_read(fh,&vsizeArc,sizeof(DWORD),&wNum);
- _dos_read(fh,szArcVolLabel,13,&wNum);
-
- if ( fVerbose )
- {
- printf( "\nArchive Volume Size = %lu ",vsizeArc );
- printf( "\nArchive Volume Label = %s \n",szArcVolLabel );
- }
-
- if ( !strcmp( szArcVolLabel, szDiskVolLabel ) )
- {
- bEquiv = TRUE;
-
- if ( (dinfoArc.low_track != dinfoDisc.low_track) ||
- (dinfoArc.hi_track != dinfoDisc.hi_track) ||
- (dinfoArc.start != dinfoDisc.start) )
- {
- bEquiv = FALSE;
- if (fVerbose)
- printf ( "\nFailed VTOC Check" );
- }
-
- if ( !fVolErr && vsizeArc != 0 && vsizeArc != vsizeDisc )
- {
- bEquiv = FALSE;
- if (fVerbose)
- printf ( "\nFailed Volume Size Check" );
- }
-
- if ( fUPC && upcArc.code != 0 && !fUPCErr )
- {
- if ( !((memcmp( upcArc.upc,upcDisc.upc,7 ) == 0) &&
- (upcArc.aframe == upcDisc.aframe)&&
- (upcArc.ctrl_adr == upcDisc.ctrl_adr)) )
- {
- bEquiv = FALSE;
- if (fVerbose)
- printf( "\nFailed UPC check" );
- }
- }
-
- if ( bEquiv ) break;
- }
- }
- else
- printf( "***WARNING***\tControl File \"%s\" Not Found, skipping.\n",
- szFullPath );
- }
-
- if ( !bEquiv )
- {
- my_free(lpbArcBuf);
- my_free(lpbDiscBuf);
- return ( SectorDump( drv ) );
- }
-
- szDiskTitle[len] = '\0';
- printf( "\nMatching Archive Found: %s\n",szDiskTitle );
-
- // The archive file consists of:
- // [Strlen(title) char ]
- // [Title char[] ]
- // [UPCCode UPCCode_Rec ]
- // [DiskInfo DiskInfo_Rec ]
- // [Volsize DWORD ]
- // [TrackInfo TnoInfo_Rec ]+
- // [DATABLOCK [AddrMode char]
- // [Sector long]
- // [ReadMode char]
- // [SectorData char[]]]+
- //
-
- for ( iTrack=dinfoArc.low_track;
- iTrack<=dinfoArc.hi_track;
- iTrack++ )
- {
- WDvRqIoiTnoInfo( drv,iTrack,&tinfoDisc );
- _dos_read(fh,&tinfoArc,sizeof(TnoInfo_Rec),&wNum);
- if ( tinfoDisc.tno != tinfoArc.tno ||
- tinfoDisc.start_tno != tinfoArc.start_tno ||
- tinfoDisc.tcntrl != tinfoArc.tcntrl )
- WarningMsg(mRequests[rITNOINFO],"Track information does not match" );
- }
- //
- // Read Sector 0 information
- //
- _dos_read( fh,&bAddrMode,1,&wNum );
- _dos_read( fh,&lSector,sizeof(DWORD),&wNum );
- _dos_read( fh,&bReadMode,1,&wNum );
- _dos_read( fh,lpbArcBuf,COOKED_SECTOR_SIZE,&wNum );
-
- TestRead( drv,lSector,bAddrMode,bReadMode,lpbDiscBuf );
-
- if (_fmemcmp( lpbArcBuf,lpbDiscBuf,COOKED_SECTOR_SIZE ) )
- {
- WarningMsg(mRequests[rREADL],"Sector 0 comparison failed" );
- }
-
- //
- // Sector Read Tests
- //
-
- while ( TRUE )
- {
-
-
- if ( _dos_read( fh, &bAddrMode,1,&wNum ) != 0)
- {
- my_free( lpbDiscBuf );
- my_free( lpbArcBuf );
- return;
- }
- else if (wNum == 0)
- break;
-
- if ( bAddrMode == REDBOOK_ADDRMODE )
- printf( "\nRedbook Addressing, " );
- else if ( bAddrMode == HSG_ADDRMODE )
- printf( "\nHSG Addressing, " );
- else
- fatalError( "DISK READ ERROR, Exiting." );
-
- _dos_read(fh,&lSector,sizeof(DWORD),&wNum);
-
- printf( "Sector %lx, ",lSector );
-
- _dos_read( fh,&bReadMode,1,&wNum);
-
- if ( bReadMode == COOKED_MODE )
- printf( "Cooked\n" );
- else if ( bReadMode == RAW_MODE )
- printf( "Raw\n" );
- else
- fatalError( "DISK READ ERROR, Exiting." );
-
- if ( bReadMode == COOKED_MODE )
- _dos_read( fh,lpbArcBuf,COOKED_SECTOR_SIZE,&wNum );
- else if ( bReadMode == RAW_MODE )
- _dos_read( fh,lpbArcBuf,RAW_SECTOR_SIZE,&wNum );
- else
- fatalError( "Error Reading File, Exiting." );
-
- if ( !(ERRORBIT & TestRead( drv,lSector,bAddrMode,bReadMode,
- lpbDiscBuf )) )
- {
- if ( bReadMode==COOKED_MODE )
- {
- if ( _fmemcmp( lpbArcBuf,lpbDiscBuf,COOKED_SECTOR_SIZE ) )
- {
- WarningMsg( mRequests[rREADL],"Cooked Comparison Differs" );
- if ( fVerbose )
- {
- printf( "\nDisc information\n" );
- HexDump( lpbDiscBuf,COOKED_SECTOR_SIZE );
- printf( "Archive information \n" );
- HexDump( lpbArcBuf,COOKED_SECTOR_SIZE );
- }
- }
- }
- else if ( fRaw )
- {
- if ( _fmemcmp( lpbArcBuf,lpbDiscBuf,RAW_SECTOR_SIZE ) )
- {
- WarningMsg( mRequests[rREADL],"Raw Comparison Differs" );
- if ( fVerbose )
- {
- printf( "\nDisc information\n" );
- HexDump( lpbDiscBuf,COOKED_SECTOR_SIZE );
- printf( "Archive information \n" );
- HexDump( lpbArcBuf,COOKED_SECTOR_SIZE );
- }
- }
- }
- }
- }
- my_free( lpbDiscBuf );
- my_free( lpbArcBuf );
-
- _dos_close( fh );
- printf( "\n\n[End of SECTOR MATCHING TESTS]\n" );
- }
-
-
- /*
- ** SectorDump( Dev_List *)
- ** - dumps all sectors in HSG and Redbook format specified in the
- ** profile.
- */
- void SectorDump( drv )
- Dev_List * drv;
- {
- extern WORD cwHSGSectors,cwRedSectors;
- extern DWORD mplHSGSector[],mplRedSector[];
- extern BYTE bInterSize, bInterSkip;
- extern FLAG fVerbose,fInteract,fRaw;
- WORD iSector,wStatus;
- char _far * lpbDiscBuf;
-
- printf( "\n\n[Sector Dump]\n" );
- if ( fInteract && !Ask( "Attempt sector dumps" ) )
- return;
-
- lpbDiscBuf = my_malloc( (size_t)RAW_SECTOR_SIZE );
-
- for ( iSector=0;iSector<cwHSGSectors;iSector++ )
- {
- if ( fRaw && (!fInteract || Ask( "Read a RAW HSG Sector" )) )
- {
- wStatus = TestRead( drv,mplHSGSector[iSector],HSG_ADDRMODE,
- RAW_MODE,lpbDiscBuf );
- if ( !(ERRORBIT&wStatus) )
- {
- if ( fVerbose )
- {
- printf( "\nRaw dump of [HSG] Sector %0.8lx:",
- mplHSGSector[iSector] );
- HexDump( lpbDiscBuf,RAW_SECTOR_SIZE );
- }
- else printf( "\nRaw [HSG] Sector %0.8lx Read." );
- }
- else if ( DRV_NOT_READY&wStatus )
- break;
-
- }
- if ( !fInteract || Ask("Read a COOKED HSG Sector") )
- {
- wStatus = TestRead( drv,mplHSGSector[iSector],HSG_ADDRMODE,
- COOKED_MODE,lpbDiscBuf );
- if ( !(ERRORBIT&wStatus) )
- {
- if ( fVerbose )
- {
- printf( "\nCooked dump of [HSG] Sector %0.8lx:",
- mplHSGSector[iSector] );
- HexDump( lpbDiscBuf,COOKED_SECTOR_SIZE );
- }
- else printf( "\nCooked [HSG] Sector %0.8lx Read." );
- }
- else if ( DRV_NOT_READY&wStatus )
- break;
- }
- }
- for ( iSector=0;iSector<cwRedSectors;iSector++ )
- {
- if ( fRaw && (!fInteract || Ask( "Read a RAW Redbook Sector" )) )
- {
- wStatus = TestRead( drv,mplRedSector[iSector],REDBOOK_ADDRMODE,
- RAW_MODE,lpbDiscBuf );
- if ( !(ERRORBIT&wStatus) )
- {
- if ( fVerbose )
- {
- printf( "\nRaw dump of [Redbook] Sector %0.8lx:",
- mplRedSector[iSector] );
- HexDump( lpbDiscBuf,RAW_SECTOR_SIZE );
- }
- else printf( "\nRaw [Redbook] Sector %0.8lx Read." );
- }
- else if ( DRV_NOT_READY&wStatus )
- break;
- }
- if (!fInteract || Ask( "Read a COOKED Redbook Sector" ))
- {
- wStatus = TestRead( drv,mplRedSector[iSector],REDBOOK_ADDRMODE,
- COOKED_MODE,lpbDiscBuf );
- if ( !(ERRORBIT&wStatus) )
- {
- if ( fVerbose )
- {
- printf( "\nCooked dump of [Redbook] Sector %0.8lx:",
- mplRedSector[iSector] );
- HexDump( lpbDiscBuf,COOKED_SECTOR_SIZE );
- }
- else printf( "\nCooked [Redbook] Sector %0.8lx Read." );
- }
- else if ( DRV_NOT_READY&wStatus )
- break;
- }
- }
- my_free( lpbDiscBuf );
- printf("\n\n[END SECTOR DUMP]\n");
- }
-
- /*
- ** TestInit( Dev_List * )
- ** - test driver call 0 INIT
- */
- void TestInit( drv )
- Dev_List *drv;
- {
- extern FLAG fInteract, fVerbose;
-
- BYTE bEndAddr,bBPB;
- WORD wStatus;
- ReportMsg( mRequests[rINIT],"" );
-
- if ( !fInteract || Ask( "Test this request" ) )
- {
- StatusTest( wStatus,WDvRqInit( drv,&bEndAddr,&bBPB),
- mRequests[rINIT] );
- if ( !( (ERRORBIT & wStatus) && (SEC_INIT_ERR & wStatus)) )
- ErrMsg( mRequests[rINIT],"Does not return UNKNOWN COMMAND error" );
- }
- }
-
- /*
- ** TestDevStat( Dev_List * )
- ** - test DevStat return value 3:6
- */
- void TestDevStat( drv )
- Dev_List *drv;
- {
- extern FLAG fRaw,fWriteMedia,fRedbook,fAudio,fInterleave,fPrefetch,
- fAudCtrl,fInteract,fVerbose,fSubInfo;
- DWORD lStatWord;
- WORD wStatus;
-
- static char * szMsgs [16] = {
- "Does not support raw mode",
- "Supports raw mode",
- "Does not support writing",
- "Supports writing",
- "Does not support Redbook addressing",
- "Supports Redbook addressing",
- "Does not support audio",
- "Supports audio",
- "Does not support interleave",
- "Supports interleave",
- "Does not support prefetch",
- "Supports prefetch",
- "Does not support audio control",
- "Supports audio control",
- "Does not support R-W subchannels ",
- "Supports R-W subchannels "
- };
-
- ReportMsg( mRequests[rIDEVSTAT],"" );
- if ( fInteract && !Ask( szLocalMsgs[0] ) )
- return;
-
- StatusTest( wStatus,WDvRqIoiDevStat( drv,&lStatWord ),
- mRequests[rIDEVSTAT] );
- ErrorTest( wStatus,mRequests[rIDEVSTAT] );
-
- //
- // Test DevStat bits against the profile information
- // provided by: fRaw,fWriteMedia,fRedbook,fAudio,fInterleave,
- // fPrefetch,fAudCtrl,fSubInfo
- //
- if (fVerbose)
- {
- ReportMsg(mRequests[rIDEVSTAT],"Returns StatusWord");
- printf("%0.8lX",lStatWord);
- }
-
- if ( EXOR( fRaw,lStatWord&DEVSTAT_RAW ) )
- {
- if ( fRaw )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[0] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[1] );
- }
- else if ( fVerbose )
- {
- if ( fRaw )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[1] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[0] );
- }
-
-
- if ( EXOR( fWriteMedia,lStatWord&DEVSTAT_WRITE ) )
- {
- if ( fWriteMedia )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[2] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[3] );
- }
- else if ( fVerbose )
- {
- if ( fWriteMedia )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[3] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[2] );
- }
-
-
- if ( EXOR( fRedbook,lStatWord&DEVSTAT_REDBOOK ) )
- {
- if ( fRedbook )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[4] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[5] );
- }
- else if ( fVerbose )
- {
- if ( fRedbook )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[5] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[4] );
- }
-
-
- if ( EXOR( fAudio,lStatWord&DEVSTAT_AUDVID ) )
- {
- if ( fAudio )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[6] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[7] );
- }
- else if (fVerbose)
- {
- if ( fAudio )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[7] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[6] );
- }
-
-
- if ( EXOR( fInterleave,lStatWord&DEVSTAT_INTERLEAVE ) )
- {
- if ( fInterleave )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[8] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[9] );
- }
- else if (fVerbose)
- {
- if ( fInterleave )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[9] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[8] );
-
- }
-
-
- if ( EXOR( fPrefetch,lStatWord&DEVSTAT_PREFETCH ) )
- {
- if ( fPrefetch )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[10] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[11] );
-
- }
- else if (fVerbose)
- {
- if ( fPrefetch )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[11] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[10] );
- }
-
-
- if ( EXOR( fAudCtrl,lStatWord&DEVSTAT_AUDCTRL ) )
- {
- if ( fAudCtrl )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[12] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[13] );
- }
- else if ( fVerbose )
- {
- if ( fAudCtrl )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[13] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[12] );
- }
-
-
- if ( EXOR ( fSubInfo,lStatWord&DEVSTAT_SUBINFO ) )
- {
- if ( fSubInfo )
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[14] );
- else
- ErrMsg( mRequests[rIDEVSTAT],szMsgs[15] );
- }
- else if ( fVerbose )
- {
- if ( fSubInfo )
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[15] );
- else
- ReportMsg( mRequests[rIDEVSTAT],szMsgs[14] );
- }
-
- }
-
- /*
- ** TestRaddr(Dev_List *)
- ** - tests IOCTLI 3:0 Raddr
- */
-
- void TestRaddr( drv )
- Dev_List *drv;
- {
- extern WORD cwErrors;
- extern FLAG fInteract,fVerbose;
- WORD wStatus;
- DWORD lAddr;
-
- ReportMsg( mRequests[rIRADDR],"" );
- if ( !fInteract || Ask( szLocalMsgs[0] ) )
- {
- StatusTest( wStatus,WDvRqIoiRaddr( drv,&lAddr ),mRequests[rIRADDR] );
- if ( !(ERRORBIT&ErrorTest( wStatus,mRequests[rIRADDR] )) );
- {
- if ( (DWORD)(drv->dev_addr) == lAddr )
- {
- ReportMsg( mRequests[rIRADDR],"Correctly Returns " );
- printf( "0x%lx",lAddr );
- }
- else
- {
- ReportMsg( mRequests[rIRADDR],"Incorrectly Returns " );
- printf( "0x%lx",lAddr );
- cwErrors++;
- }
- }
- }
- }
- /*
- ** TestReset( Dev_List * )
- ** - tests IOCTLO: 12.2 Reset
- */
- void TestReset( drv )
- Dev_List *drv;
- {
- extern FLAG fInteract, fVerbose;
- WORD wStatus;
- ReportMsg( mRequests[rORESET],"" );
- if ( !fInteract || Ask( szLocalMsgs[0] ) )
- {
- StatusTest( wStatus,WDvRqIooReset( drv ),mRequests[rORESET] );
- ErrorTest( wStatus,mRequests[rORESET] );
- }
- }
-
- /*
- ** TestLockDoor( Dev_List * )
- ** - tests IOCTLO: 12.1 LockDoor
- */
-
- /*
- ** The tests can be altered to prompt the user to confirm that the door
- ** is indeed locked.
- */
- void TestLockDoor( drv )
- Dev_List * drv;
- {
- extern FLAG fInteract, fVerbose;
-
- DWORD lStatWord,lOldState;
- WORD wStatus;
-
- ReportMsg( mRequests[rOLOCKDOOR],"" );
-
- if ( !fInteract || Ask( szLocalMsgs[1] ) )
- {
-
- StatusTest( wStatus,WDvRqIoiDevStat( drv,&lOldState ),mRequests[rIDEVSTAT] );
- ErrorTest( wStatus,mRequests[rIDEVSTAT] );
-
- if ( lOldState&DEVSTAT_DRLOCK )
- {
- //
- // lock door if unlocked
- //
-
- StatusTest( wStatus,WDvRqIooLockDoor( drv,LOCK_DOOR ),mRequests[rOLOCKDOOR] );
- ErrorTest( wStatus,mRequests[rOLOCKDOOR] );
- }
- else
- {
- //
- // unlock door if locked
- //
-
- StatusTest( wStatus,WDvRqIooLockDoor( drv,UNLOCK_DOOR ),
- mRequests[rOLOCKDOOR] );
- ErrorTest( wStatus,mRequests[rOLOCKDOOR] );
- }
- StatusTest( wStatus,WDvRqIoiDevStat( drv,&lStatWord ),mRequests[rIDEVSTAT] );
-
- ErrorTest( wStatus,mRequests[rIDEVSTAT] );
-
- if ( (lStatWord&DEVSTAT_DRLOCK)==(lOldState&DEVSTAT_DRLOCK) )
- WarningMsg( mRequests[rOLOCKDOOR],"Unable to change Door State" );
-
- //
- // Try to make sure that the door is locked
- //
-
- StatusTest( wStatus,WDvRqIooLockDoor( drv,UNLOCK_DOOR ),mRequests[rOLOCKDOOR] );
- ErrorTest( wStatus,mRequests[rOLOCKDOOR] );
- }
- }